package com.vita.testCore;

import com.vita.testCore.value.CvtMetaInfo;
import com.vita.testCore.value.ValueStore;

import java.util.UUID;

public abstract class CvtExecute<I,O> extends Execute implements CvtMetaInfo {
    private final static String KEY = "CvtExecute";
    private String id;

    private ValueStore<I,O> value;

    {
        id = UUID.randomUUID().toString().replaceAll("-","");
    }

    public ValueStore<I,O> getInfo(){
        return this.value;
    }

    public void input(I input){
        if(value == null){
            this.value = new ValueStore<I,O>(input);
        }else {
            this.value.setInput(input);
        }
    }

    public void output(O output){
        if(value == null){
            throw new ClassCastException("input缺省");
        }else {
            this.value.setOutput(output);
        }
    }


    public <C> void output(C context,O output){}

    public void run(){};

    public void run(I i){};

    public void run(I i,O o){};

    @Override
    public String getKey() {
        return KEY;
    }

    @Override
    public String getId() {
        return id;
    }
}
